package com.bicon.life.core.base.common.utils;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by lenovo on 2016/12/27.
 */
public class ListUtils {
    /*
     * 截取列表
     */
    public static <T> List<T> getSubListPage(List<T> list, int pageNo, int pageSize) {
        if (list == null || list.isEmpty()) {
            return new ArrayList<T>();
        }
        int startIndex = pageNo > 0 ? (pageNo - 1) * pageSize : 1;
        int endIndex = pageSize > 0 ? startIndex + pageSize : startIndex + 10;
        if (startIndex > endIndex || startIndex > list.size()) {
            return new ArrayList<T>();
        }
        if (endIndex > list.size()) {
            endIndex = list.size();
        }
        return list.subList(startIndex, endIndex);
    }
}
